/**
 * Copyright (C), 2019-2022, 宇信融汇
 * FileName: Mar07
 * Author:   666
 * Date:     2022/4/5 23:24
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 666           修改时间           版本号              描述
 */
package com.singleton;

/**
 * @Classname Mar07
 * @Description 静态内部类    jvm加载类的时候只会加载一次，所以内部类在创建外部类的时候，只会创建一次对象
 * @Date 2022/4/5 23:24
 * @Created by 666
 */
public class Mar07 {


    private static class Mar07Holder {
        private static final Mar07 INSTANCE = new Mar07();
    }

    public static Mar07 getInstance() {
        return Mar07Holder.INSTANCE;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(() ->
                    System.out.println(Mar07.getInstance().hashCode())
            ).start();
        }
    }
}
